import React, { Component } from 'react';
import {
    Button,
    View,
    Text,
    NativeModules,
    DeviceEventEmitter
} from 'react-native'


DeviceEventEmitter.addListener('Test_NativeEmitter', function (data) {
    setTimeout(() => {
        alert(data+"4567890");
    }, 2000);
   
});

class ViewOne extends Component {

    static navigationOptions = {
        headerTitle: 'ViewOne'
    }
    async testPromise(type) {
        var returnVal = await NativeModules.BaseBridge.testPromise(type);
        alert(returnVal);
    }



    render() {
        return (
            <View>
                <Button
                    onPress={() => { this.props.navigation.navigate('Two') }}
                    title='点击进入ViewTow'
                />

                <Button
                    onPress={() => {
                        NativeModules.BaseBridge.show('hello')
                    }}
                    title='点击进入ViewTow'
                />

                <Button
                    onPress={() => {
                        this.testPromise("1");
                    }}
                    title='testPromise'
                />

                 <Button
                    onPress={() => {
                        NativeModules.BaseBridge.abc()
                    }}
                    title='testPromise'
                />



            </View>
        )
    }

}

export default ViewOne;